package com.aaa.controller;


import com.aaa.entity.MyReturn;
import com.aaa.service.TestResultSasService;
import com.aaa.service.TesterSASService;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author yudejie2020
 */
@Controller
@RequestMapping("resultSas")
public class TestResultSasController extends BaseController{
    MyReturn myReturn=new MyReturn();
    @Autowired
    private TestResultSasService testResultSasService;
    @Autowired
    private TesterSASService testerSASService;


    @RequestMapping("deleteTestResultSasById.do")
    @ResponseBody
    public  MyReturn deleteTestResultSasById(Integer id){
        boolean deleteTesterById = testerSASService.deleteTesterById(id);
        boolean deleteTestResultSasByID = testResultSasService.deleteTestResultSasByID(id);
        if (deleteTesterById&&deleteTestResultSasByID){
            return super.getSuccessReturn(myReturn);

        }
        return super.getFailReturn(myReturn);
    }
    @RequestMapping("deleteTestResultSasBatch.do")
    @ResponseBody
    public  MyReturn deleteTestResultSasBatch(String id){
        boolean deleteTestResultSasBatch = testResultSasService.deleteTestResultSasBatch(id);
        boolean deleteTesterBatch = testerSASService.deleteTesterBatch(id);
        if (deleteTesterBatch&&deleteTestResultSasBatch){
            return super.getSuccessReturn(myReturn);
        }
        return super.getFailReturn(myReturn);
    }




    /**
     * 接收前台传回的json参数
     *
     */
    @RequestMapping("resultSas.do")
    @ResponseBody
    public MyReturn resultSas(String res){
        System.out.println(res);
        //转list<map>
        List<Map> maps = JSON.parseArray(res, Map.class);
        boolean b=testResultSasService.insertTestSas(maps);
        if (b){
            return super.getSuccessReturn(myReturn);
        }
        return super.getFailReturn(myReturn);
    }


}
